/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.lvyh.lightframe.sharding.client.common;

import lombok.Data;

/**
 * @author lvyh 2021/10/25.
 */
@Data
public class ShardModel {

    /**
     * Logical data source name
     */
    private String logicDatasourceName;

    /**
     * Logical table name
     */
    private String logicTableName;

    /**
     * Shard key field
     */
    public String shardKey;

    /**
     * Shard algorithm type
     */
    public String shardAlg;

    /**
     * Number of database slices
     */
    public int dbShardNum;

    /**
     * Number of table slices
     */
    public int tableShardNum;

    /**
     * Distributed primary key field
     */
    private String pkId;

    /**
     * Distributed primary key generation strategy
     */
    private String idGenType;

    /**
     * Business unit of distributed primary key
     */
    private String idGenTag;


    public static class Builder {
        private ShardModel instance;

        public Builder(ShardModel q) {
            this.instance = q;
        }

        public Builder() {
            this(new ShardModel());
        }

        public Builder setLogicDatasourceName(String logicDatasourceName) {
            this.instance.logicDatasourceName = logicDatasourceName;
            return this;
        }

        public Builder setLogicTableName(String logicTableName) {
            this.instance.logicTableName = logicTableName;
            return this;
        }

        public Builder setShardKey(String shardKey) {
            this.instance.shardKey = shardKey;
            return this;
        }

        public Builder setShardAlg(String shardAlg) {
            this.instance.shardAlg = shardAlg;
            return this;
        }

        public Builder setDbShardNum(int dbShardNum) {
            this.instance.dbShardNum = dbShardNum;
            return this;
        }

        public Builder setTableShardNum(int tableShardNum) {
            this.instance.tableShardNum = tableShardNum;
            return this;
        }

        public Builder setPkId(String pkId) {
            this.instance.pkId = pkId;
            return this;
        }

        public Builder setIdGenType(String idGenType) {
            this.instance.idGenType = idGenType;
            return this;
        }

        public Builder setIdGenTag(String idGenTag) {
            this.instance.idGenTag = idGenTag;
            return this;
        }

        public ShardModel build() {
            return this.instance;
        }
    }

}
